/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package main.java.cn.webrx;

import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * <p>Project: jse2204 - FileCopyDemo
 * <p>Powered by webrx On 2022-09-21 17:46:04
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class FileCopyDemo {
    public static void main(String[] args) {
        String f1 = "d:/abc/g1.jpg";
        try (var is = new FileInputStream(f1); var os = new FileOutputStream("c:/girl3.jpg")) {
            //os.write(is.readAllBytes());

            //效率低
            //int b = 0;
            //while((b = is.read())!=-1){
            //    os.write(b);
            //}

            //is.transferTo(os);


            byte[] buffer = new byte[1024 * 25];
            int read;
            while ((read = is.read(buffer)) >= 0) {
                os.write(buffer, 0, read);
            }


        } catch (Exception e) {

        }
    }
}
